import { Tools } from "../utils/Tools";

export class InstanceBasic {


    private _updateEnabled:boolean = false;

    private _intervalTime:number = 1000;


    
    public setUpdateEnabled(flag: boolean, intervalTime: number = 1000): void {

        if(this._updateEnabled == flag){
            return;
        }

        this._intervalTime = intervalTime;
        this._updateEnabled = flag;



        if(flag){
            this._update(Tools.getServerTime());
            
        }

    }

    private _update(servertime:number):void{
        if(!this._updateEnabled){
            return;
        }


        this.update(servertime);

        setTimeout(()=>{
            this._update(Tools.getServerTime());
        },this._intervalTime);

    }
    public update(servertime: number): void {
        
    
    }
}